/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.gov.igac.observatorio.entidades.propuesta;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author bigbang
 */
@Entity
@Table(name = "tiporecurso")
@NamedQueries({
    @NamedQuery(name = "Tiporecurso.findAll", query = "SELECT t FROM Tiporecurso t"),
    @NamedQuery(name = "Tiporecurso.findByIdTipoRecurso", query = "SELECT t FROM Tiporecurso t WHERE t.idTipoRecurso = :idTipoRecurso"),
    @NamedQuery(name = "Tiporecurso.findByTipo", query = "SELECT t FROM Tiporecurso t WHERE t.tipo = :tipo")})
public class Tiporecurso implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idTipoRecurso")
    private Integer idTipoRecurso;
    @Size(max = 100)
    @Column(name = "tipo")
    private String tipo;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tiporecurso")
    private List<Presupuesto> presupuestoList;
    @JoinColumn(name = "ItemCosto_idItemCosto", referencedColumnName = "idItemCosto")
    @ManyToOne
    private Itemcosto itemcosto;

    public Tiporecurso() {
    }

    public Tiporecurso(Integer idTipoRecurso) {
        this.idTipoRecurso = idTipoRecurso;
    }

    public Integer getIdTipoRecurso() {
        return idTipoRecurso;
    }

    public void setIdTipoRecurso(Integer idTipoRecurso) {
        this.idTipoRecurso = idTipoRecurso;
    }

    public String getTipo() {
        return tipo;
    }

    public void setTipo(String tipo) {
        this.tipo = tipo;
    }

    public List<Presupuesto> getPresupuestoList() {
        return presupuestoList;
    }

    public void setPresupuestoList(List<Presupuesto> presupuestoList) {
        this.presupuestoList = presupuestoList;
    }

    public Itemcosto getItemcosto() {
        return itemcosto;
    }

    public void setItemcosto(Itemcosto itemcosto) {
        this.itemcosto = itemcosto;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTipoRecurso != null ? idTipoRecurso.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tiporecurso)) {
            return false;
        }
        Tiporecurso other = (Tiporecurso) object;
        if ((this.idTipoRecurso == null && other.idTipoRecurso != null) || (this.idTipoRecurso != null && !this.idTipoRecurso.equals(other.idTipoRecurso))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.tipo;
    }
    
}
